require(extrafont)
require(tidyverse)
library(ggpubr)
library(gridExtra)
library(cowplot)
cbPalette <- c( "#000000","#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
##### load the node data frame for the bipartite graph
nodes <- read.csv("BipartiteNetwork_nodes.csv")
head(nodes)
##### created in gephi and saved as png
gephi1<-ggdraw() +
draw_image("Bipart.png")
gephi1
tol_muted<- c('#332288','#44AA99','#117733','#999933','#DDCC77','#CC6677','#882255','#88CCEE')
phylo_bipaplotlegend <- ggplot(nodes)+
geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),color="#d9d9d9",size=0.01)+
geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=Phylo),size=2,shape=19)+
theme_void()+ theme(legend.position='bottom',legend.direction="vertical")+
scale_colour_manual(values=tol_muted)+scale_fill_manual(values=tol_muted)+
# scale_color_manual(values=pal8_no_light_yellow)+scale_fill_manual(values=pal8_no_light_yellow)+
coord_fixed(ratio = 1)+labs(color='',fill='')+
guides(color=guide_legend(,override.aes = list(size = 5,shape=15),ncol=4))+
theme(text=element_text(size=15, family="Times New Roman"))
phylo_bipaplotlegend
bipa_piwiplot<- ggplot(nodes)+
geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),colour="#d9d9d9",size=0.01)+
geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=PIWI),size=2)+
theme_void()+#+scale_color_brewer(type='qual')+
scale_color_manual(values=c('#31688EFF','#FDE725FF',"#d9d9d9" ),labels=c('no PIWI','PIWI','TEs'))+
labs(color='')+coord_fixed(ratio = 1)+
guides(color=guide_legend(,override.aes=list(shape=15,size=5)))+
theme(text=element_text(size=15, family="Times New Roman"),legend.position='bottom')
bipa_piwiplot
bipa_dnmtplot<- ggplot(nodes)+
geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),colour="#d9d9d9",size=0.01)+
geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=DNMT),size=2)+
theme_void()+ theme(legend.position='bottom')+
scale_color_manual(values=c("#440154FF",'#35B779FF' ),labels=c('no DNMT','DNMT'))+
labs(color='')+coord_fixed(ratio = 1)+
guides(color=guide_legend(,override.aes=list(shape=15,size=5)))+
theme(text=element_text(size=15, family="Times New Roman"),legend.text.align = 0)
bipa_dnmtplot
options(repr.plot.width=15, repr.plot.height=15)
myfigure <- as_ggplot(arrangeGrob(gephi1,phylo_bipaplotlegend,bipa_piwiplot,bipa_dnmtplot, ncol=2,nrow=2))+
draw_plot_label(label = c("A", "B", "C",'D'), size = 20,
x = c(0,0.5,0,0.5),
y = c(1,1,0.5,0.5))
myfigure